package cn.bj.yu.function;

import java.util.function.Supplier;

/**
 * @author 周宇
 * @create 2020-08-14 16:06
 * 供给新接口 Supplier 没有参数只有返回值
 */
public class SupplierDemo {
    public static void main(String[] args) {
        Supplier<Integer> supplier = new Supplier<Integer>() {
            @Override
            public Integer get() {
                System.out.println("进入get方法...");
                return 1024;
            }
        };

        //lambda优化
        Supplier<Integer> lsupplier = () -> {
            System.out.println("进入get方法...");
            return 1024;
        };
        System.out.println(supplier.get());
        System.out.println(lsupplier.get());
    }
}